﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using ChoJu.Single.ViewModel;

namespace ChoJu.Single.Views
{
    /// <summary>
    /// CalibrationView.xaml 的交互逻辑
    /// </summary>
    public partial class CalibrationView : UserControl
    {
        public CalibrationView()
        {
            InitializeComponent();

            var vm = new CalibrationVM();
            vm.FocusLastItem += FocusLastItemFunction;

            this.DataContext = vm;
        }

        private void DgData_LoadingRow(object sender, DataGridRowEventArgs e)
        {
            DataGrid dg = (DataGrid)sender;
            dgData.ScrollIntoView(dg.Items[dg.Items.Count - 1]);
        }

        public void FocusLastItemFunction()
        {
            if (dgData.Items.Count > 3)
                dgData.ScrollIntoView(dgData.Items[dgData.Items.Count - 1]);

            if (lstLog.Items.Count > 3)
                lstLog.ScrollIntoView(lstLog.Items[lstLog.Items.Count - 1]);
        }
    }
}
